Operators, in combination with punctuation, are executed in a particular order. Normally, operators are executed from highest to lowest priority. When two operators are of equal priority, left to right execution applies.
The normal order of execution is overridden by the use of parentheses. Expressions in parentheses are executed first. In a set of parentheses, operators are executed from highest to lowest priority. Operators of equal priority within parentheses are executed from left to right. Operators are ranked and executed in this order:
Operator |
Order of Execution |
( ) |
Highest priority—executed first |
- (Unary minus (negative)) |
Second highest priority—executed after operations in parentheses |
* / (Multiplication and division) |
Third highest priority. |
+ - & (Addition, subtraction, string concatenation) |
Fourth priority |
! != (Logical not and logical not equal) |
Fifth priority |
AND OR |
Sixth priority |
= (Assignment) |
Lowest priority |
Here are two example assignment statements. The components and execution order of each statement is fully explained.
$AMOUNT = @("BEG_BAL") + 100.00
Target variable |
$AMOUNT |
Source expression |
@("BEG_BAL") + 100.00 |
Calculation |
Takes the value in the section variable field named BEG_BAL adds 100.00 and places the result in the target decimal variable named $AMOUNT |
Order of execution |
Reads the expression from left to right |
$AMOUNT = (@("PremBasis1") + @("PremBasis2")) * @("Prem/OpsRate1")/100
Target variable |
$AMOUNT |
Source expression |
(@("PremBasis1") + @("PremBasis2")) * @("Prem/OpsRate1")/100 |
Calculation |
Takes the value in the section variable field named PremBasis1 adds the value in the section variable field named PremBasis2; multiples the total of these two fields by the value in the section variable field Prem/OpsRate1; then divides the total by 100 and places the result in the target decimal variable named AMOUNT. |
Order of execution |
Reads the expression from left to right applying the priority of operators (multiplication and division prior to addition). However, the first set of parenthesis overrides the normal priority, so the addition operation is performed first. |
© Copyright 2015, Oracle and/or its affiliates. All rights reserved. Legal notices.